contextBridge.exposeInMainWorld('electronAPI', {  
  send: (channel, data) => {  
    // 验证传递的 channel  
    let validChannels = ["toMain"];  
    if (validChannels.includes(channel)) {  
      ipcRenderer.send(channel, data);  
    }  
  },  
  receive: (channel, func) => {  
    let validChannels = ["fromMain"];  
    if (validChannels.includes(channel)) {  
      ipcRenderer.on(channel, (event, ...args) => func(...args));  
    }  
  }  
});